<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <ul>
        <li>11</li>
        <li>22</li>
        <li>33</li>
    </ul>
    <script>
        //展开运算符: ...
        //一. 展开数组
        // var arr = [1, 2, 3, 4];
        // var arr2 = [5];
        // var res = [...arr, ...arr2];
        // console.log(res);//  [1, 2, 3, 4, 5]

        //    var arr = [3,1,2,5,4];
        //    var res = Math.max(...arr);
        //    console.log(res);// 5


        //可以把伪数组转成数组:
        // function fn(){
        //     console.log(arguments);// Arguments(3) [1, 2, 3, callee: ƒ, Symbol(Symbol.iterator): ƒ]
        //     //通过 Array.from  来把伪数组转成数组
        //     var arr=  Array.from(arguments);
        //     console.log(arr);// [1,2,3]
        // }
        // fn(1,2,3)



        // function fn(){
        //     console.log(arguments);// Arguments(3) [1, 2, 3, callee: ƒ, Symbol(Symbol.iterator): ƒ]
        //     //通过展开运算符 来转换
        //     var arr = [...arguments];
        //     console.log(arr);// [1, 2, 3]
        // }
        // fn(1,2,3)


        // let lis = document.getElementsByTagName("li");
        // console.log(lis);
        // [...lis].forEach(item => item.onclick = () => console.log(111))


        // 处理不定参数, rest剩余参数
        // fn = (a, ...args) => console.log(args)
        // fn(1, 2, 3, 4)//  [2, 3, 4]



        //对象的展开
        //合并对象,合并并配置
        let obj1={name:"张三"};
        let obj2={age:20};
        var obj = {...obj1,...obj2};
        console.log(obj);// {name: '张三', age: 20}

        //字符串的展开
        var str = "abcdefg";
        var arr=[...str];
        console.log(arr);// ['a', 'b', 'c', 'd', 'e', 'f', 'g']
    </script>
</body>

</html>